package hairdressing;

import java.util.LinkedList;
import java.util.concurrent.*;

public class Hairdressers extends Thread
{
        static int num_of_cust = 0;
        static int num_of_exits = 0;
        static Semaphore max_capacity = new Semaphore(20, true);
	static Semaphore sofa = new Semaphore(4, true);
	static Semaphore barber_chair = new Semaphore(3, true);
	static Semaphore Cust_read = new Semaphore(0, true);
        static Semaphore[] finished;
        static Semaphore Leave_b_chair	= new Semaphore(0, true);
        static Semaphore payment = new Semaphore(0, true);
        static Semaphore receipt = new Semaphore(0, true);
        static Semaphore coord = new Semaphore(3, true);       
        static LinkedList<Integer> waiting_list = new  LinkedList<Integer>();
        
        Hairdressers(int _barber_chair, int _max_capacity, int _sofa)
        {
            barber_chair = new Semaphore(_barber_chair, true);
            max_capacity = new Semaphore(_max_capacity, true);
            sofa = new Semaphore(_sofa, true);
        }
        
        Hairdressers()
        {
        }
                
	public void Work(int Customer, int Hairdresser, int Cashier)
        {           
                finished = new Semaphore[Customer];
                for (int i = 0; i < Customer; i++) 
                {
                        finished[i] = new Semaphore(0, true);
			new Customer().start();
                        num_of_exits++;
		}
            
		for (int i = 0; i < Hairdresser; i++) 
                {
			new Hairdresser(i+1).start();
		}
                
		for (int i = 0; i < Cashier; i++)
                {
			new Cashier().start();                      
		}    
                
                new Stop().start();
        }        
}
